.class Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;
.super Ljava/lang/Object;
.source "ViewPagerAdapter.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/opongo/blogapp/adapter/ViewPagerAdapter;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = "UpdateAdapter"
.end annotation


# instance fields
.field private p:I

.field final synthetic this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;


# direct methods
.method public constructor <init>(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;I)V
    .locals 0
    .parameter
    .parameter "p"

    .prologue
    .line 312
    iput-object p1, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 314
    iput p2, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    .line 315
    return-void
.end method


# virtual methods
.method public run()V
    .locals 14

    .prologue
    .line 319
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->mAdapterArray:Ljava/util/ArrayList;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$0(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)Ljava/util/ArrayList;

    move-result-object v9

    iget v10, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    invoke-virtual {v9, v10}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Lcom/opongo/blogapp/adapter/PostListAdapter;

    .line 320
    .local v7, mAdapter:Lcom/opongo/blogapp/adapter/PostListAdapter;
    const/4 v9, 0x0

    iput-boolean v9, v7, Lcom/opongo/blogapp/adapter/PostListAdapter;->isLockLoading:Z

    .line 322
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget-object v9, v9, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    .line 323
    iget-object v10, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget-object v10, v10, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v10}, Lcom/opongo/blogapp/manager/DatabaseManager;->getTableName()Ljava/lang/String;

    move-result-object v10

    iget v11, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    .line 322
    invoke-virtual {v9, v10, v11}, Lcom/opongo/blogapp/manager/DatabaseManager;->queryForBlogTypeID(Ljava/lang/String;I)I

    move-result v0

    .line 325
    .local v0, blogTypeID:I
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget-object v10, v9, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->query:Ljava/lang/String;

    const/4 v9, 0x3

    new-array v11, v9, [Ljava/lang/Object;

    const/4 v9, 0x0

    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v12

    aput-object v12, v11, v9

    const/4 v9, 0x1

    iget-object v12, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->order:[Ljava/lang/String;
    invoke-static {v12}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$1(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)[Ljava/lang/String;

    move-result-object v12

    iget v13, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    aget-object v12, v12, v13

    aput-object v12, v11, v9

    const/4 v12, 0x2

    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->DESC:[Ljava/lang/Boolean;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$2(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)[Ljava/lang/Boolean;

    move-result-object v9

    iget v13, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    aget-object v9, v9, v13

    invoke-virtual {v9}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v9

    if-eqz v9, :cond_2

    const-string v9, "DESC"

    :goto_0
    aput-object v9, v11, v12

    invoke-static {v10, v11}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v8

    .line 328
    .local v8, queryFormat:Ljava/lang/String;
    invoke-virtual {v7}, Lcom/opongo/blogapp/adapter/PostListAdapter;->getCursor()Landroid/database/Cursor;

    move-result-object v1

    .line 329
    .local v1, currentcursor:Landroid/database/Cursor;
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->activity:Landroid/app/Activity;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$3(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)Landroid/app/Activity;

    move-result-object v9

    invoke-virtual {v9, v1}, Landroid/app/Activity;->stopManagingCursor(Landroid/database/Cursor;)V

    .line 331
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget-object v9, v9, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v9, v8}, Lcom/opongo/blogapp/manager/DatabaseManager;->query(Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v2

    .line 332
    .local v2, cursor:Landroid/database/Cursor;
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->activity:Landroid/app/Activity;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$3(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)Landroid/app/Activity;

    move-result-object v9

    invoke-virtual {v9, v2}, Landroid/app/Activity;->startManagingCursor(Landroid/database/Cursor;)V

    .line 334
    sget-boolean v9, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->DEBUG:Z

    if-eqz v9, :cond_0

    .line 335
    invoke-static {}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$4()Ljava/lang/String;

    move-result-object v9

    const-string v10, "onPostExecute"

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 337
    :cond_0
    invoke-virtual {v7, v2}, Lcom/opongo/blogapp/adapter/PostListAdapter;->changeCursor(Landroid/database/Cursor;)V

    .line 339
    invoke-virtual {v7}, Lcom/opongo/blogapp/adapter/PostListAdapter;->removeListViewHeader()V

    .line 341
    invoke-virtual {v7}, Lcom/opongo/blogapp/adapter/PostListAdapter;->isEmpty()Z

    move-result v9

    if-eqz v9, :cond_3

    .line 342
    invoke-virtual {v7}, Lcom/opongo/blogapp/adapter/PostListAdapter;->removeListViewFooter()V

    .line 343
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->activity:Landroid/app/Activity;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$3(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)Landroid/app/Activity;

    move-result-object v9

    .line 344
    const-string v10, "layout_inflater"

    invoke-virtual {v9, v10}, Landroid/app/Activity;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v9

    .line 343
    check-cast v9, Landroid/view/LayoutInflater;

    .line 345
    const v10, 0x7f03000c

    const/4 v11, 0x0

    const/4 v12, 0x0

    invoke-virtual {v9, v10, v11, v12}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

    move-result-object v4

    .line 346
    .local v4, footerView:Landroid/view/View;
    const/4 v9, 0x0

    invoke-virtual {v7, v4, v9}, Lcom/opongo/blogapp/adapter/PostListAdapter;->setListViewFooter(Landroid/view/View;Landroid/widget/ListView;)V

    .line 351
    .end local v4           #footerView:Landroid/view/View;
    :goto_1
    invoke-virtual {v7}, Lcom/opongo/blogapp/adapter/PostListAdapter;->notifyDataSetChanged()V

    .line 353
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget v9, v9, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->post_id:I

    if-eqz v9, :cond_1

    iget v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    if-nez v9, :cond_1

    .line 354
    invoke-interface {v2}, Landroid/database/Cursor;->requery()Z

    .line 356
    new-instance v5, Landroid/content/Intent;

    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->context:Landroid/content/Context;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$6(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)Landroid/content/Context;

    move-result-object v9

    .line 357
    const-class v10, Lcom/opongo/blogapp/activities/PostViewScrollActivity;

    .line 356
    invoke-direct {v5, v9, v10}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 358
    .local v5, intent:Landroid/content/Intent;
    const-string v9, "POSITION"

    iget-object v10, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget v10, v10, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->positionInDetailView:I

    invoke-virtual {v5, v9, v10}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 359
    const-string v9, "TABLENAME"

    iget-object v10, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget-object v10, v10, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v10}, Lcom/opongo/blogapp/manager/DatabaseManager;->getTableName()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v5, v9, v10}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 360
    const-string v9, "QUERY"

    invoke-virtual {v5, v9, v8}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 362
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    #getter for: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->activity:Landroid/app/Activity;
    invoke-static {v9}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$3(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;)Landroid/app/Activity;

    move-result-object v9

    invoke-virtual {v9, v5}, Landroid/app/Activity;->startActivity(Landroid/content/Intent;)V

    .line 364
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    const/4 v10, 0x0

    iput v10, v9, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->post_id:I

    .line 368
    .end local v5           #intent:Landroid/content/Intent;
    :cond_1
    :try_start_0
    iget-object v6, v7, Lcom/opongo/blogapp/adapter/PostListAdapter;->listView:Landroid/widget/ListView;

    check-cast v6, Leu/erikw/PullToRefreshListView;

    .line 369
    .local v6, listview:Leu/erikw/PullToRefreshListView;
    invoke-virtual {v6}, Leu/erikw/PullToRefreshListView;->onRefreshComplete()V
    :try_end_0
    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_0} :catch_0

    .line 374
    .end local v6           #listview:Leu/erikw/PullToRefreshListView;
    :goto_2
    return-void

    .line 325
    .end local v1           #currentcursor:Landroid/database/Cursor;
    .end local v2           #cursor:Landroid/database/Cursor;
    .end local v8           #queryFormat:Ljava/lang/String;
    :cond_2
    const-string v9, "ASC"

    goto/16 :goto_0

    .line 348
    .restart local v1       #currentcursor:Landroid/database/Cursor;
    .restart local v2       #cursor:Landroid/database/Cursor;
    .restart local v8       #queryFormat:Ljava/lang/String;
    :cond_3
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->this$0:Lcom/opongo/blogapp/adapter/ViewPagerAdapter;

    iget v10, p0, Lcom/opongo/blogapp/adapter/ViewPagerAdapter$UpdateAdapter;->p:I

    #calls: Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->addFooterLoadMore(I)V
    invoke-static {v9, v10}, Lcom/opongo/blogapp/adapter/ViewPagerAdapter;->access$5(Lcom/opongo/blogapp/adapter/ViewPagerAdapter;I)V

    goto :goto_1

    .line 370
    :catch_0
    move-exception v3

    .line 371
    .local v3, e:Ljava/lang/NullPointerException;
    invoke-virtual {v3}, Ljava/lang/NullPointerException;->printStackTrace()V

    goto :goto_2
.end method
